package com.ball.dao;

import com.ball.entity.User;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface UserMapper {
    @Insert("insert into user(id,username,password,mail,walletName,walletAddress,money) values(null,#{username},#{password},#{mail},#{walletName},#{walletAddress},#{money})")
    void add(User user);

    @Update("update user set username=#{username},password=#{password},mail=#{mail},walletName=#{walletName},walletAddress=#{walletAddress},money=#{money} where id = #{id}")
    void update(User user);

    @Delete("delete from user where id= #{id}")
    void deleteUserById(@Param("id") int id);

    @Delete("delete from user where username= #{username}")
    void deleteUserByName(@Param("username") String username);

    @Select("select * from user  where id= #{id}")
    User queryUserById(@Param("id") int id);

    @Select("select * from user where username= #{username}")
    User queryUserByUsername(@Param("username")String username);

    @Select("select * from user order by id desc")
    List<User> queryUserList();

}
